<?php

namespace app\qsapi\controller;

use app\qsapi\service\YunPhoneService;
use think\response\Json;


/**
 * 云挂机模块
 */
class YunPhone extends BaseController
{
    /**
     * Notes: 获取启动参数
     * User: liubaoqiang
     * DateTime: 2024/12/16 11:05
     * @return Json
     */
    public function actionPrams(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->actionPrams($member_id));
    }

    /**
     * Desc : 获取商户客户端临时clientToken与clientSecretKey接口
     * User : you name
     * Date : 2024-03-22 13:54
     * @return Json
     */
    public function getYunPhoneUserRegister(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->getYunPhoneUserRegister($member_id));
    }

    /**
     * Notes: 【用户】获取接入端点地址
     * User: liubaoqiang
     * DateTime: 2024/12/10 10:55
     * @return Json
     */
    public function getYunPhoneUserAccess(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->getYunPhoneUserAccess($member_id));
    }

    /**
     * Notes: 【用户】创建并绑定云机
     * User: liubaoqiang
     * DateTime: 2024/12/10 10:57
     * @return Json
     */
//    public function createYunPhoneToUser(): Json
//    {
//        $member_id = $this->request->getMemberId();
//        return json((new YunPhoneService)->createYunPhoneToUser($member_id, $this->request->post()));
//    }


    /**
     * Notes: 【用户】获取设备列表
     * User: liubaoqiang
     * DateTime: 2024/12/10 11:24
     * @return false|string
     */
    public function getYunPhoneUserList()
    {
        $member_id = $this->request->getMemberId();
        $result = (new YunPhoneService)->getYunPhoneUserList($member_id, $this->request->post('userDeviceId'));
        return json_encode($result,JSON_BIGINT_AS_STRING);
    }

    /**
     * Notes: 【用户】续费功能
     * User: liubaoqiang
     * DateTime: 2024/12/10 13:30
     * @return Json
     */
//    public function renewYunPhoneUser(): Json
//    {
//        $member_id = $this->request->getMemberId();
//        return json((new YunPhoneService)->renewYunPhoneUser($member_id,$this->request->post('userDeviceId'),$this->request->post('increaseHour')));
//    }

    /**
     * Notes: 【用户】结束挂机功能
     * User: liubaoqiang
     * DateTime: 2024/12/10 13:30
     * @return Json
     */
    public function stopYunPhoneUser(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->stopYunPhoneUser($member_id, $this->request->post('userDeviceId')));
    }

    /**
     * Notes: 【用户】结束挂机任务结果查询
     * User: liubaoqiang
     * DateTime: 2024/12/10 13:30
     * @return Json
     */
    public function stopYunPhoneUserResult(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->stopYunPhoneUserResult($member_id, $this->request->post('deviceBizTaskId')));
    }

    /**
     * Notes: 【用户】重启设备
     * User: liubaoqiang
     * DateTime: 2024/12/10 13:30
     * @return Json
     */
    public function restartYunPhoneUser(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->restartYunPhoneUser($member_id, $this->request->post('userDeviceId')));
    }

    /**
     * Notes: 【用户】重启设备记录
     * User: liubaoqiang
     * DateTime: 2024/12/10 15:49
     * @return Json
     */
    public function restartYunPhoneUserRecord(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->restartYunPhoneUserRecord($member_id, $this->request->post('userDeviceId')));
    }

    /**
     * Notes: 【用户】回收设备
     * User: liubaoqiang
     * DateTime: 2024/12/10 15:54
     * @return Json
     */
    public function recoveryYunPhoneUser(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->recoveryYunPhoneUser($member_id, $this->request->post('userDeviceId')));
    }

    /**
     * Notes: 【用户】更新用户设备有效期
     * User: liubaoqiang
     * DateTime: 2024/12/10 15:54
     * @return Json
     */
    public function updateYunPhoneUserValidate(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->updateYunPhoneUserValidate($member_id, $this->request->post()));
    }

    /**
     * Notes: 【用户】换绑商品
     * User: liubaoqiang
     * DateTime: 2024/12/10 15:55
     * @return Json
     */
    public function exchangeMachineYunPhoneUser(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->exchangeMachineYunPhoneUser($member_id, $this->request->post('itemCode'), $this->request->post('userDeviceId')));
    }

    /**
     * Notes: 【SDK】获取 ClientToken 接口（此 token 使用在sdk）
     * User: liubaoqiang
     * DateTime: 2024/12/17 18:29
     * @return Json
     */
    public function getSdkToken(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->getSdkToken($member_id));
    }

    /**
     * Notes: 修改云机名称
     * User: liubaoqiang
     * DateTime: 2024/12/31 09:32
     * @return Json
     */
    public function setYunPhoneName(): Json
    {
        $member_id = $this->request->getMemberId();
        return json((new YunPhoneService)->setYunPhoneName($member_id, $this->request->post('userDeviceId'), $this->request->post('name')));
    }

}
